package online.lmds.sdmanage.main.message;

import org.springframework.integration.mqtt.outbound.MqttPahoMessageHandler;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;

import javax.annotation.Resource;

/**
 * Created by Brighten Ma on 2017/5/1.
 */
public class MqttClient {

    @Resource
    private MqttPahoMessageHandler mqtt;

    public void publish(String messaeg){
        Message<String> message = MessageBuilder.withPayload(messaeg)
                .setHeader(MqttHeaders.TOPIC, "robot_server").build();
        mqtt.handleMessage(message);
        System.out.println("成功");
    }
}
